package com.gw.youTubeAudioAPI.decode
{
	import flash.utils.ByteArray;
	
	/**
	 * this class binds a bytearray with flv specific syntax
	 **/
	
	public class FLV_Wrapper
	{
		private var _flv:ByteArray;
		public function FLV_Wrapper(flv:ByteArray)
		{
			this._flv = flv;
		}
		//bytearray class takes care of all the bit masking etc during reads and writes so we use int and uint as containers
		public function readUB():uint 
		{
			return _flv.readUnsignedByte();
		}
		public function readUI8():uint 
		{
			return _flv.readUnsignedByte();
		}
		public function readUI24():uint //assumes big-endian... I think :S
		{
			var short:	uint = _flv.readUnsignedShort();//16 bits
			var byte:	uint = _flv.readUnsignedByte();	//8 bits
			return (short<<4)|byte;//rest will be zeros
		}
		public function readUI32():uint 
		{
			return _flv.readUnsignedInt();
		}
		public function get length():uint 
		{
			return _flv.length;
		}
		public function set position(position:uint):void 
		{
			_flv.position = position;
		}
		public function get position():uint
		{
			return _flv.position;
		}
		public function readBytes(bytes:ByteArray, offset:uint = 0, length:uint = 0):void
		{
			_flv.readBytes(bytes, offset, length);
		}
	}
}